package com.zy.recursion;

/**
 * Created by zhaoyi on 2019/8/27.
 * 原地翻转字符串
 * https://leetcode-cn.com/explore/orignial/card/recursion-i/256/principle-of-recursion/1198/
 */
public class ReverseStr {


    public void reverseString(char[] s) {
        if (s == null || s.length == 0) {
            return;
        }
        reverse(s, 0, s.length - 1);
    }

    public void reverse(char[] str, int start, int end) {
        if (start < end) {
            char tmp = str[start];
            str[start] = str[end];
            str[end] = tmp;
            reverse(str, start + 1, end - 1);
        }


    }


}
